<template>
    <div class="box">
        <van-form @submit="onSubmit">
            <van-cell-group inset>

                <van-field v-model="RYD_Name" name="RYD_Name" label="名称" placeholder="请输入名称"
                    :rules="[{ required: true, message: '请输入正确内容' }]" size="large" maxlength='10' />

                <van-field v-model="RYD_Phone" name="RYD_Phone" label="联系方式" placeholder="请输入分机号或者手机号"
                    :rules="[{ required: true, message: '请输入正确内容' }]" size="large" maxlength='10' />

            </van-cell-group>

            <div style="margin: 16px;">
                <van-button round block type="primary" native-type="submit">
                    提交修改
                </van-button>
            </div>
        </van-form>

    </div>
</template>

<script setup>

import axios from '@/utils/axios';
import { inject, ref } from 'vue';
import { Toast } from 'vant';


let nav = inject('nav');
nav.showLeft = true;
nav.textLeft = '返回';
nav.title = 'IT 资料修改';
nav.showRight = false;

let RYD_Name = ref('');
let RYD_Phone = ref('');


let RYD_UserId = inject('RYD_UserId');


let onSubmit = (values) => {


    Toast.loading({
        message: '修改中',
        duration: 0,
        overlay: true
    });
    axios({
        method: 'Put',
        url: '/api/setUserInfo',
        data: {
            ...values,
            RYD_Id:RYD_UserId,
        }
    }).then(res => {
        if (res == true) {
            Toast.success({ overlay: true, message: '修改成功' });
            
        } else {
            Toast.fail({ overlay: true, message: '修改失败' })
        }
    }).catch(() => {
        Toast.fail({ overlay: true, message: '错误' })
    })
}
initDate();
function initDate() {

    axios.get("/api/GetUserInfo?RYD_UserId=" + RYD_UserId).then(res => {
        RYD_Name.value = res.userName;
        RYD_Phone.value = res.userPhone;
    })
}

</script>


<style scoped>
/* .box {
    padding-top: ;
} */
</style>